<div class="right_side_operate_area">
	<?php 
		App::import('Helper', 'Accp');
	    $accp = new AccpHelper();
		$user = $session->read("User");
	?>
	<div class="right_side_title left" id="count"></div>
    <?php 
		echo '<div class="left item_add_btn">';
		echo '<a style="margin-left:15px;" id="sendalert" onclick="showmsgview()">发送私信</a>';
		echo '</div>';
	?>
	
	<div class="right search_box">
		<form onsubmit="return searchperson()">
	    	<div class="left search_text">
	    		<?php echo $form->text('Project.search_person',array('placeholder'=>'搜索人员名称','value'=>$personName, 'id'=>'personName', 'class'=>'text_box'));?>
	    	</div>
	        <div class="left search_btn"><input type="submit" value=""/></div>
        </form>
        <div class="clear"></div>
    </div>
	
	<div class="right search_box">
		<form onsubmit="return searchperson()">
	    	<div class="left search_text">
	    		<?php echo $form->text('Project.search_person',array('placeholder'=>'搜索高校服务方向','value'=>$serviceDirection, 'id'=>'serviceDirection', 'class'=>'text_box'));?>
	    	</div>
	        <div class="left search_btn"><input type="submit" value=""/></div>
        </form>
        <div class="clear"></div>
    </div>
	
	<div class="right search_box">
		<form onsubmit="return searchperson()">
	    	<div class="left search_text">
	    		<?php echo $form->text('Project.search_person',array('placeholder'=>'搜索人员负责方向','value'=>$conDirection, 'id'=>'conDirection', 'class'=>'text_box'));?>
	    	</div>
	        <div class="left search_btn"><input type="submit" value=""/></div>
        </form>
        <div class="clear"></div>
    </div>
	
	<div class="right search_box">
		<form onsubmit="return searchperson()">
	    	<div class="left search_text">
	    		<?php echo $form->text('Project.search_person',array('placeholder'=>'搜索高校名称','value'=>$cgName, 'id'=>'cgName', 'class'=>'text_box'));?>
	    	</div>
	        <div class="left search_btn"><input type="submit" value=""/></div>
        </form>
        <div class="clear"></div>
    </div>
	
    <div class="clear"></div>
</div>	
   
<div class="right_side_scollbar">
    <div class="detail_info_panel">
        <div class="items_list">
        	<table>
            	<tr>
            		<th>企业名称</th> 
                    <th style=text-align:left><input name='chooseAll' id='chooseAll' type='checkbox' onclick="ChkAllClick('choice','chooseAll')">姓名</th>
                    <th>联系电话</th>
                    <th>邮箱</th> 
                    <th>负责方向</th>        
                </tr>
                <?php 
					foreach($objcolleages as $colleage)
					{	
						$colleage_id = $colleage["Colleage"]["id"];
						$colleage_name = $colleage["Colleage"]["colleage_name"];
						$contact_name = $colleage["Colleage"]["contact"];//获取负责人的id
						$contact_tel = $colleage["Colleage"]["tel"];//获取负责人的电话
						$contact_email = $colleage["Colleage"]["email"];//获取负责人的邮件
						
						$colleage_people = $colleage["CgPerson"];
						$contact = array("name"=>$contact_name,"tel"=>$contact_tel,'email'=>$contact_email,'direction'=>'法人','colleage_id'=>$colleage_id);
						if($direction_flag && $person_flag)
							array_unshift($colleage_people, $contact);
						
						$people_num = count($colleage_people);
						$i = 0;
						
						if(!empty($colleage_people))
						{
							foreach($colleage_people as $key=>$person)
							{
								$name = $person["name"];
								$tel = $person["tel"];
								$email = $person["email"];
								$direction = $person["direction"];
								$userid = $accp->getuserid($objusers,$email);
								
								echo "<tr class='per_list'>";		
								if($i == 0)											
									echo "<td rowspan='".$people_num."'>$colleage_name</td>";	
								echo "<label><td style='text-align:left'><input name='choice' type='checkbox' value='$userid'>$name</td></label>";
								echo "<td>$tel</td>";
								echo "<td>$email</td>";
								echo "<td>".$str->sub_len($direction,10)."</td>";		
								echo "</tr>";
								$i++;
							}
						}
					}
				?>
            </table>
		</div>
    </div>
</div>

<div id="message" title="发送私信"></div>

<script>
var webpath=$("#getpath").attr('href');
var urlpath=webpath+"users/colleageperson?seach=all";

function searchperson()
{	
	var cgName=$("#cgName").val();
	if(cgName=="搜索高校名称"){
		cgName="";
	}
	var conDirection = $("#conDirection").val();
	if(conDirection=="搜索人员负责方向"){
		conDirection="";
	}
	var serviceDirection=$("#serviceDirection").val();
	if(serviceDirection=="搜索高校服务方向"){
		serviceDirection="";
	}
	var personName=$("#personName").val();
	if(personName=="搜索人员名称"){
		personName="";
	}
	
	if(cgName=="" && conDirection=="" && serviceDirection=="" && personName==""){
		location.href=urlpath;
	}else{	
		if(cgName.trim() != ""){
			urlpath+="&cgName="+encodeURIComponent(cgName.trim());
		}
		if(conDirection.trim() != ""){
			urlpath+="&conDirection="+encodeURIComponent(conDirection.trim());
		}
		if(serviceDirection.trim() != ""){
			urlpath+="&serviceDirection="+encodeURIComponent(serviceDirection.trim());
		}
		if(personName.trim()!=""){
			urlpath+="&personName="+encodeURIComponent(personName.trim());
		}		
		location.href=urlpath;
	}
	return false;
}


function ChkAllClick(sonName, cbAllId)
{
   var arrSon = document.getElementsByName(sonName);
	 var cbAll = document.getElementById(cbAllId);
	 var tempState=cbAll.checked;
	 for(i=0;i<arrSon.length;i++) 
	 {
	  	if(arrSon[i].checked!=tempState)
	           arrSon[i].click();
	 }
}

$("input[name='choice']").click(countChecked);

function countChecked() {
  var n = $("input[name='choice']:checked").length;
  $("#count").eq(0).html("<strong>有<font color='red'>"+n+"</font> 个被选中!</strong>");

  var s=''; 
  $('input[name="choice"]:checked').each(function(){ 
    s+=$(this).val()+','; 
  }); 
  $("#useridlist").val(s);
  $("#sender").val(<?php echo $user["id"];?>);
}
function showmsgview(){

	 var n = $("input[name='choice']:checked").length;

	 if(n==0)
	 {
		 showmessage("请选择联系人");
	 }else
	 {
		 $("#message").dialog( "open" );

	 }
}
$(function() {
	$("#message").dialog({
		autoOpen: false,
		height: 300,
		width: 800,
		modal:true,
		resizable: false
	});
	$("#cancel").click(function() {
		$("#message").dialog( "close" );
	});
});
function getmsgpage(){	
	var urlpath="<?php echo $accp->path;?>/priMsg";	
	$.ajax({     	   
       url: urlpath, 
       success:function(data){
       	$("#message").html(data);
       	$(":file").uniform();
       }
      })
    $("#sender").val(<?php echo $user["id"];?>);
}
getmsgpage();
countChecked();

</script>